﻿/******************************************************************************
* File description: downloadManager.h
* Function: 从https服务器下载文件
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/

#ifndef DOWNLOADMANAGER_H
#define DOWNLOADMANAGER_H

#include <QFile>
#include <QDebug>

#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>

#include <QTimer>
#include <QEventLoop>
#ifdef Q_OS_WINDOWS
#include <windows.h>
#endif

class DownloadManager : public QObject
{

    Q_OBJECT
private:
    DownloadManager();
public:
    static DownloadManager& I();

    Q_INVOKABLE int downloadFile(QString url, QString localPath, bool block=false);       // 返回下载Id，后面可通过Id查询下载进度以及信号通知下载完成

signals:
    void sigDownloadFinish(int id);

public slots:
    void onDownloadFinished();

private:
    QFile file;

    bool isDownloading = false;


};

#endif // DOWNLOADMANAGER_H
